<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
    <%@ page import="java.sql.*"%>
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>桌号选择</title>
<title>桌号选择</title>
<style>
    /* 简单的CSS样式 */
    body {
        font-family: Arial, sans-serif;
        text-align: center;
    }
    form {
        margin: 20px;
    }
    select, button {
        margin: 5px;
    }
    h1 {
    color: #5d478b;
  }

  .form-item {
    margin: 15px 0;
  }

  label {
    display: inline-block;
    width: 150px;
    text-align: right;
    margin-right: 10px;
  }

  input[type="text"],
  select {
    width: 200px;
    padding: 5px;
    border: 1px solid #ddd;
    border-radius: 3px;
  }

  button {
    padding: 10px 20px;
    background-color: #5d478b;
    color: white;
    border: none;
    border-radius: 5px;
    cursor: pointer;
  }

  button:hover {
    background-color: #4c3575;
  }
</style>
<%
String restaurant_name = request.getParameter("restaurant_name");
String customer_name = request.getParameter("customer_name");
//
Class.forName("org.mariadb.jdbc.Driver");
Connection conn = DriverManager.getConnection("jdbc:mariadb://localhost:3306/mealdb?user=root&password=1230321");
Statement stmt = conn.createStatement();
ResultSet rs = stmt.executeQuery("select * from `table` WHERE state = '空闲';");
%>
</head>
<body>
    <h1>请选择当前空闲桌号</h1>
    <form id="table-selection-form" action="saveTableNum.jsp?customer_name=<%=customer_name%>&restaurant_name=<%=restaurant_name %>" method="post">
       <div class="form-item">
      <label for="name">用户名：</label>
      <input type="text" id="customer_name" name="customer_name" value="<%=customer_name%>" required readonly="readonly" class="form-input">
    </div>
    <div class="form-item">
      <label for="restaurant_name">餐厅：</label>
      <input type="text" id="restaurant_name" name="restaurant_name" value="<%=restaurant_name %>" readonly="readonly" required class="form-input">
    </div>
    <div class="form-item">
        <label for="table-number">请选择桌号：</label>
        <select id="table-number" name="table-number">
        
            <%
			while (rs.next()) {
				String num = rs.getString("num");
			%>
            <option value="<%=num%>">桌号 <%=num%></option>
            <%}; %>
        </select>
        <br>
          </div>
        <button type="submit">提交</button>
    </form>

</body>
</html>